package cn.jark.example.web.service.impl;

import cn.jark.example.web.entity.User;
import cn.jark.example.web.service.TestService;
import com.alibaba.csp.sentinel.annotation.SentinelResource;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cache.annotation.CachePut;
import org.springframework.cache.annotation.Cacheable;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.stereotype.Service;

/**
 * @author 雨一直夏灬(须知少年凌云志, 曾许人间第一流)
 * @since 2020-10-30
 */
@Slf4j
@Service
public class TestServiceImpl implements TestService {

    @Autowired
    RedisTemplate<String, Object> redisTemplate;

    @Override
    @SentinelResource(value = "hello")
    @Cacheable(value = "gogo", keyGenerator = "keyGenerator")
    public String sayHello() {
        log.info("gogogogo");
        redisTemplate.opsForValue().set("jack", new User("jack", 132));
        return "hello";
    }

}
